import App from './App'

//此处遇到极其凶险的bug
import uView from '@/uni_modules/uview-ui' // 这里为第一处




// 引入主包依赖
import TencentCloudChat  from "@tencentcloud/chat";
import TUICore from "@tencentcloud/tui-core";
// import './uni.promisify.adaptor'
import VueCompositionAPI from "@vue/composition-api";



Vue.use(VueCompositionAPI);



import Util from './common/js/util.js'
import Http from './common/js/http.js'
import Config from './common/js/config.js'

// #ifndef VUE3
import Vue from 'vue'

Vue.use(uView) // 这里为第三处

Vue.config.productionTip = false
import share from '@/common/js/share.js';
Vue.mixin(share);
App.mpType = 'app'
Vue.config.productionTip = false
Vue.prototype.$util = Util;
Vue.prototype.$api = Http; 
Vue.prototype.$config = Config; 
try {
  function isPromise(obj) {
    return (
      !!obj &&
      (typeof obj === "object" || typeof obj === "function") &&
      typeof obj.then === "function"
    );
  }

  // 统一 vue2 API Promise 化返回格式与 vue3 保持一致
  uni.addInterceptor({
    returnValue(res) {
      if (!isPromise(res)) {
        return res;
      }
      return new Promise((resolve, reject) => {
        res.then((res) => {
          if (res[0]) {
            reject(res[0]);
          } else {
            resolve(res[1]);
          }
        });
      });
    },
  });
} catch (error) { }

const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'


export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif